<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<style>
    body {
        margin: 0 !important
    }

    .addoptional {
        background-color: #f2f2f2;
        width: 100%;
        height: 100%;
        box-sizing: border-box;
        background-size: cover;
        /* position: fixed */
    }

    .addoptional .loadingHead {
        width: 100%;
        display: flex;
        height: 4.1065rem;
        background: white;
        box-shadow: 0 0 40px #e4e4e4;
        padding-right: 1.3462rem;
        padding-left: 1.3162rem;
        box-sizing: border-box;
    }

    .addoptional .loadingHead .head {
        width: 100%;
        display: flex;
        justify-content: space-between;
        padding-top: 0.60rem;
        padding-bottom: 0.57rem;
        box-sizing: border-box;
    }

    .addoptional .loadingHead .head img:nth-child(1) {
        height: 80%;
        width: 6rem;
        position: relative;
        transform: translateY(20%)
    }

    .addoptional .loadingHead .head img:nth-child(2) {
        height: 80%;
        width: 2.35rem;
        position: relative;
        transform: translateY(20%)
    }

    .optional {
        width: 100%;
        height: 100%;
        background-color: #f0f5ef;
        /* margin-top: 0.6844rem */
    }

    .optional .myaddoption {
        height: 2.7903rem;
        background: linear-gradient(to right, #5bcc98, #2fb184);
        border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);
        line-height: 2.7903rem;
        font-size: 1rem;
        color: #c7f3dc;
        text-align: center
    }

    .optional .optionalmiddle {
        background: linear-gradient(to right, #5bcc98, #2fb184);
        height: 7.2391rem;
        padding: 1.21rem 0.8423rem;
        display: flex;
        box-sizing: border-box;
        flex-wrap: wrap;
        align-items: center;
        /* justify-content: space-between */
    }

    .optional .optionalmiddle div {
        width: 25%;
        color: white;
        padding-left: 0.5423rem;
        box-sizing: border-box;
        /* padding-top: 0.3158rem;
        padding-bottom: 0.3158rem;
        padding-right: 0.5423rem; */
        padding: 0.2rem;
        padding-left: 0.1rem;
        padding-right: 0.1rem;
        text-align: center;
        opacity: 0.7
    }

    .optional .optionalmiddle .selcol {
        border-radius: 25px;
        opacity: 1;
        background-color: rgba(255, 255, 255, 0.15)
    }

    .optional .optioncontent {
        height: 3.8433rem;
        background-color: #ffffff;
        padding: 1.0529rem 0.8421rem;
        box-sizing: border-box;
        border-bottom: 1px solid #f2f2f2;
    }

    .optional .optioncontent img {
        float: left;
        height: 100%;
        width: auto
    }

    .optional .optioncontent .optionlogo {
        float: left;
        height: 100%;
        line-height: 1.7375rem;
        font-size: 1.1rem;
        margin-left: 0.6844rem;
    }

    .optional .optioncontent .addTo {
        float: right;
        font-size: 1.05rem;
        height: 100%;
        line-height: 1.7375rem;
        /* padding: 0.3685rem 1.4214rem; */
        /* padding: 0 2.4214rem; */
        text-align: center;
        border-radius: 25px;
        color: white;
        width: 5.21rem;
        background: linear-gradient(to right, #5bcc98, #2fb184);
    }

    .optional .optioncontent .addition {
        float: right;
        font-size: 1.05rem;
        height: 100%;
        line-height: 1.7375rem;
        text-align: center;
        /* padding: 0.3685rem 1.4214rem; */
        /* padding: 0 .4214rem; */
        width: 5.21rem;
        border-radius: 25px;
        color: black;
        background: #e5e5e5;
    }

    .optional .optioncontent1213 {
        display: none;
    }

    .optional .optioncontent0 {
        display: block;
    }
</style>

<body>
    <div class="addoptional">
        <div class="loadingHead">
            <div class="head">
                <img src="/mimage/logo.png" alt="" @click="returone">
                <img src="/mimage/mylogo.png" alt="" @click="Jump">
            </div>
        </div>
        <div class="optional">
            <div class="myaddoption">添加自选</div>
            <div class="optionalmiddle">
                <% if(getnav.length){ %>
                    <% getnav.forEach( (item,index) => { %>
                        <div name="<%= item.code %>" @click="sellectCorle (<%= index %>)" :class="{selcol:<%= index %>==thisindex}">
                            <%= item.yesnDescribe %>
                        </div>
                        <% }) %>
                            <% } %>
            </div>
            <div>
                <div class="optioncontent1213" :class="'optioncontent'+index" v-for='(item,index) in list'>
                    <div class="optioncontent " v-for="(subitem,index2) in item.data " :name="subitem.id">
                        <img :src="subitem.logo" alt="">
                        <div class="optionlogo">
                            {{subitem.company}}
                        </div>
                        <div class="addition" onclick="subadd(this)" v-show="subitem.selStatus == 1">
                            已添加
                        </div>
                        <div class="addTo" onclick="subaddone(this)" v-show="subitem.selStatus != 1">
                            添加
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script>
    function subadd(a) {
        var indexname = $(a).parent().attr('name')
        var indexcode = $(".selcol").attr('name')
        let parm = {
            // userId: 66691,
            delStatus: 0,
            navigationCode: indexcode,
            articleId: indexname
        }
        axios.post('/yesUser/delyesSelectionadd', parm).then(res => {
            window.location.reload()
        })
    }
    function subaddone(a) {
        var indexname = $(a).parent().attr('name')
        var indexcode = $(".selcol").attr('name')
        let parm = {
            // userId: 66691,
            navigationCode: indexcode,
            articleId: indexname
        }
        axios.post('/yesUser/yesSelectionadd', parm).then(res => {
            window.location.reload()
        })
    }
    var app = new Vue({
        el: ".addoptional",
        data() {
            return {
                thisindex: 0,
                usergetnavlis: [],
                list: []
            }
        },
        created() {
            this.setRem(28.43);
            this.fontSize(198);
            this.bb()
            // this.aa()
        },
        methods: {
            bb() {
                axios.post('/yesUser/getNavigationList', { //不需要ID
                }).then(res => {
                    this.list = res.data.data
                    this.aa()
                })
            },
            aa() {
                axios.post('/yesUser/usergetarticle').then(res => {
                    this.usergetnavlis = res.data.data
                    this.list.forEach((ele, index) => {
                        ele.data.forEach((ele2, index2) => {
                            this.usergetnavlis.forEach((ele3, index3) => {
                                ele3.data.forEach((ele4, index4) => {
                                    if (ele2.id == ele4.id) {
                                        if (ele4.selStatus) {
                                            ele2.selStatus = ele4.selStatus
                                        }
                                    }
                                })
                            });
                        });
                    })
                })
            },
            setRem(itemNum) {
                //设置字体rem
                let size = itemNum || 38;
                window.onresize = remSize;
                remSize();
                function remSize() {
                    let html = document.getElementsByTagName("html")[0],
                        w = html.clientWidth;
                    w = w > 768 ? 768 : w;
                    html.style.fontSize = w / size + "px";
                }
            },
            fontSize(itemnum) {
                let html = document.getElementsByTagName("html")[0];
                let a = html.style.fontSize;
            },
            Jump() {
                window.location.href = "/m/mregistered"
            },
            returone() {
                window.location.href = '/m'
            },
            sellectCorle(index) {
                this.thisindex = index
                let seleindex = '.optioncontent' + (this.thisindex)
                $(seleindex).css('display', 'block').siblings().css("display", "none")
                // document.getElementsByClassName(seleindex)[0].style.display="block"
                // let indexlength=document.getElementsByClassName(seleindex)
                // for (let index = 0; index < indexlength.length; index++) {
                //     document.getElementsByClassName(seleindex)[index].style.display='block'
                // }
            }
        }
    })
</script>

</html>